'''图片的爬取和存储
'''
import  requests
import  os


url="https://edu-image.nosdn.127.net/3321D6673EB82C94D08E1B80E8344166.jpg"
root=r"D:\爬虫学习2021\pictures\\"
path=root+url.split('/')[-1]
try:
    if not os.path.exists(root):
        os.mkdir(root)
    if not os.path.exists(path):
        r=requests.get(url)
        with open(path,"wb") as f :
            f.write(r.content)
            f.close()
    else:
        print("文件已存在")
except:
    print("爬取失败")
